package dissertation.examples.ejb21.message;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;

public class LogClient {
    public static void main(String[] args) throws Exception {
        Context ctx = new InitialContext(System.getProperties());

        TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("javax.jms.TopicConnectionFactory");
        TopicConnection connection = factory.createTopicConnection();
        TopicSession session = connection.createTopicSession(
                false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = (Topic) ctx.lookup("testtopic");
        TopicPublisher publisher = session.createPublisher(topic);

        TextMessage msg = session.createTextMessage();
        msg.setText("This is a test message.");
        publisher.publish(msg);
    }
}
